package com.itlaoqi.springcloud.memberserviceopenfeign.controller;

import com.itlaoqi.springcloud.memberserviceopenfeign.client.MessageService;
import com.itlaoqi.springcloud.memberserviceopenfeign.entity.CallbackResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class MemberController {
    @Resource
    private MessageService messageService;

    @GetMapping("/snb")
    @ResponseBody
    public String sendNewBook(String mobile,String bookname){
        String message = "[HOTBOOK]您预购的" + bookname + "已到货，明日将送到您府上";
        CallbackResult result = messageService.sendSMS(mobile,bookname);
        if (result.getCode().equals("0")){
            return "短信已成功送达，服务返回：" +result.getResult();
        }else {
            return "短信发送失败，失败原因:" + result.getResult();
        }
    }
}
